#include<occi.h>
#include<stdio.h>
#include<iostream>
using namespace oracle::occi;
using namespace std;

class DBAccess{
public:
	DBAccess(){}

	void openQuery(string query){
		openConnection();
		executeQuery(query);
		closeConnection();
	}

private:
	Environment* env;	// Environment variable for oracle
	Connection* conn;	// Connection variable for oracle

	void openConnection(){
		//create environment and connection
		//cout << "OCIAttrGet with OCI_ATTR_USERNAME = " << OCIAttrGet((void*)OCI_ATTR_USERNAME, NULL, NULL, NULL, NULL, NULL) << endl;
		env = Environment::createEnvironment (Environment::OBJECT);
		conn = env->createConnection( "Andrew", "voron11229" );
		cout << "Environment and Connection created" << endl;
	}

	void closeConnection(){
		//terminate environment and connection
		env->terminateConnection(conn);
		Environment::terminateEnvironment(env);
		cout << "Environment and Connection terminated" << endl;
	}

	void executeQuery(string query){
		//execute a SQL statement
		Statement* stmt = conn->createStatement();
		stmt->setSQL(query);//"INSERT into BASKET_TAB VALUES ('cherry', 10)");
		stmt->executeUpdate();
		conn->terminateStatement(stmt);
	}

};